/**
 * Created by xieliang on 11/12/2016.
 */

var imserver = function(){

    var users = new Array();

    var connections = new Array();

    this.create = function(server){
        
        var io = require('socket.io')(server);

        io.on('connection', function (socket) {

            socket.emit('connected', '连接成功!');

            socket.on('login', function (user) {
                connections[user] = socket;
            });

            socket.on('private message',function (fff,from,to,msg) {
                console.log(fff);
                console.log(from);
                console.log(to);
                console.log(msg);

                socket.emit('private message',fff,from,to,msg);
            });
        });
    };
};

module.exports = new imserver();
